<template>
  <div>
    Get请求
    <p v-for="(item,index) in list" :key="index">{{item.id}}</p>
    <div>
      <ul>
        <!-- 有个问题 一条数据 循环出来三个li 不是想要的 -->
        <li v-for="(item,index) in newsData" :key="index">
          <h1>{{index}}{{item.title}}</h1>
          <p>{{item.describes}}</p>
          <p>{{item.name}}</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: "get",

  data() {
    return {
      id: "36D57B0C00F643DAA68EAA65A10F470F",
      newsData: "",
      list: [
        {
          id: "1",
          name: "name",
        },
        {
          id: "1",
          name: "name",
        },
      ],
    };
  },
  created() {
    //组件被创建的时候执行
    // this.$axios.get("http://special.mdweekly.cn/rqxa/rqxa/works/getWorks?id=" + this.id)
    //   .then((res) => {
    //     console.log(res.data);
    //   })
    //   .catch((error) => {
    //     console.log(error);
    //   });
    this.$axios("http://special.mdweekly.cn/rqxa/rqxa/works/getWorks", {
      params: {
        id: this.id,
      },
    })
      .then((res) => {
        this.newsData = res.data;
        console.log(res.data);
      })
      .catch((error) => {
        console.log(error);
      });
  },
};
</script>

<style scoped>
</style>